home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Harvest C 1.3 / Source Code / CHarvestApp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-20  |  16.5 KB  |  734 lines  |  [TEXT/ALFA]

  1. /*
  2.     Harvest C
  3.     Copyright 1992 Eric W. Sink.  All rights reserved.
  4.     
  5.     This file is part of Harvest C.
  6.     
  7.     Harvest C is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU Generic Public License as published by
  9.     the Free Software Foundation; either version 2, or (at your option)
  10.     any later version.
  11.     
  12.     Harvest C is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.     
  17.     You should have received a copy of the GNU General Public License
  18.     along with Harvest C; see the file COPYING.  If not, write to
  19.     the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.     
  21.     Harvest C is not in any way a product of the Free Software Foundation.
  22.     Harvest C is not GNU software.
  23.     Harvest C is not public domain.
  24.  
  25.     This file may have other copyrights which are applicable as well.
  26.  
  27. */
  28.  
  29. /*****
  30.  * CHarvestApp.c
  31.  *
  32.  *    Application methods for Harvest C
  33.  *
  34.  *  Copyright © 1990 Symantec Corporation.  All rights reserved.
  35.  *
  36.  *****/
  37.  
  38. #include "CHarvestApp.h"
  39. #include "CHarvestDoc.h"
  40. #include "CDLOGDialog.h"
  41. #include "CDialogText.h"
  42. #include "CDLOGDirector.h"
  43. #include "CAppleEvent.h"
  44. #include "CBartender.h"
  45. #include "Commands.h"
  46. #include "HarvestCommands.h"
  47. #include "CSourceFile.h"
  48. #include "CDataFile.h"
  49. #include "CList.h"
  50. #include "Global.h"
  51. #include <AppleEvents.h>
  52. #include <TBUtilities.h>
  53.  
  54. extern    OSType    gSignature;
  55. extern  CBartender *gBartender;
  56. extern  CDesktop *gDesktop;
  57. extern  CHarvestApp *gApplication;
  58. extern    CHarvestDoc *gProject;
  59. extern CursHandle    gIBeamCursor;        /* I-beam for text views            */
  60. extern CursHandle    gWatchCursor;        /* Watch cursor for waiting            */
  61. extern CBureaucrat    *gGopher;            /* First in line to get commands    */
  62.  
  63. Str255 MyVersion;
  64.  
  65. #define        kExtraMasters        4
  66. #define        kRainyDayFund        20480
  67. #define        kCriticalBalance    20480
  68. #define        kToolboxBalance        20480
  69.  
  70. int app_refnum;
  71.  
  72. OSErr
  73. FindSystemHeaders(short vRefNum,long dirID,char *name,FSSpec *buf)
  74. {
  75.     OSErr result;
  76.     short vnum;
  77.     long id;
  78.     CInfoPBRec spec1;
  79.     CInfoPBRec spec2;
  80.     HParamBlockRec pb;
  81.     Str255 pname;
  82.     strcpy((char *) pname,name);
  83.     c2pstr(pname);
  84.     
  85.     HGetVol(NULL,&vnum,&id);
  86.     
  87.     spec1.hFileInfo.ioNamePtr = pname;
  88.     spec1.hFileInfo.ioFlAttrib = 0x10;
  89.     spec2.hFileInfo.ioNamePtr = NULL;
  90.     spec2.hFileInfo.ioFlAttrib = 0x10;
  91.     pb.csParam.ioNamePtr = NULL;
  92.     pb.csParam.ioCompletion = NULL;
  93.     pb.csParam.ioSearchBits = fsSBFullName + fsSBFlAttrib;
  94.     pb.csParam.ioSearchInfo1 = &spec1;
  95.     pb.csParam.ioSearchInfo2 = &spec2;
  96.     pb.csParam.ioSearchTime = -1;
  97.     pb.csParam.ioCatPosition.initialize = 0;
  98.     pb.csParam.ioOptBuffer = NULL;
  99.     pb.csParam.ioOptBufSize = 0;
  100.     pb.csParam.ioVRefNum = vnum;
  101.     pb.csParam.ioMatchPtr = buf;
  102.     pb.csParam.ioReqMatchCount = 1;
  103.     
  104.     result = PBCatSearchSync(&pb);
  105.     if (!pb.csParam.ioActMatchCount) return -43;
  106.     return result;
  107. }
  108.  
  109. static short        _current_working_directory = 0;
  110. static short        _current_working_vrefnum = 0;
  111. static long            _current_working_dirid = 2;
  112.  
  113. set_current_wd(vRefNum, dirID)
  114. int        vRefNum;
  115. long    dirID;
  116.     {
  117.     int            myerr;
  118.     WDPBRec        wpb;
  119.  
  120.     wpb.ioCompletion = 0;
  121.     wpb.ioVRefNum = vRefNum;
  122.     wpb.ioNamePtr = (unsigned char *) NULL;
  123.     wpb.ioWDDirID = dirID;
  124.     myerr = PBHSetVol(&wpb, FALSE);
  125.     if (myerr != noErr) {
  126.         return myerr;
  127.         }
  128.     else {
  129.         wpb.ioWDProcID = 'ERIK';
  130.         myerr = PBOpenWD(&wpb, FALSE);
  131.         if (myerr == noErr) {
  132.             _current_working_directory = wpb.ioVRefNum;
  133.             _current_working_vrefnum = wpb.ioWDVRefNum;
  134.             _current_working_dirid = dirID;
  135.             }
  136.         else {
  137.             return myerr;
  138.             }
  139.         }
  140.     }
  141.  
  142. void CHarvestApp::IHarvestApp(void)
  143.  
  144. {
  145.     CApplication::IApplication( kExtraMasters, kRainyDayFund, 
  146.                         kCriticalBalance, kToolboxBalance);
  147.     
  148.  
  149.      Init(0,NULL);
  150.      
  151.      BeachBalls[0] = GetCursor(500);
  152.      FailNILRes(BeachBalls[0]);
  153.     HNoPurge( (Handle) BeachBalls[0]);
  154.     
  155.      BeachBalls[1] = GetCursor(501);
  156.      FailNILRes(BeachBalls[1]);
  157.     HNoPurge( (Handle) BeachBalls[1]);
  158.     
  159.      BeachBalls[2] = GetCursor(502);
  160.      FailNILRes(BeachBalls[2]);
  161.     HNoPurge( (Handle) BeachBalls[2]);
  162.     
  163.      BeachBalls[3] = GetCursor(503);
  164.      FailNILRes(BeachBalls[3]);
  165.     HNoPurge( (Handle) BeachBalls[3]);
  166.     
  167.     BeachIndex = 0;
  168.  
  169.     app_refnum = CurResFile();
  170.     
  171.     {
  172.         FSSpec spec;
  173.  
  174.         FCBPBRec fcbpb;
  175.         OSErr err;
  176.         fcbpb.ioNamePtr = (void *) HarvestCTree.name;
  177.         fcbpb.ioVRefNum = 0;
  178.         fcbpb.ioRefNum = CurResFile();
  179.         fcbpb.ioFCBIndx = 0;
  180.         err = PBGetFCBInfoSync(&fcbpb);
  181.         HarvestCTree.vRefNum = fcbpb.ioVRefNum;
  182.         HarvestCTree.parID = fcbpb.ioFCBParID;
  183.         
  184.         set_current_wd(HarvestCTree.vRefNum,HarvestCTree.parID);
  185.  
  186.         {
  187.             CInfoPBRec cfb;
  188.             Str255 tempPath;
  189.             CopyPString("\p(Harvest C Headers)",tempPath);
  190.             cfb.hFileInfo.ioNamePtr = tempPath;
  191.             cfb.hFileInfo.ioDirID = HarvestCTree.parID;
  192.             cfb.hFileInfo.ioVRefNum = HarvestCTree.vRefNum;
  193.             cfb.hFileInfo.ioFDirIndex = 0;
  194.             err = PBGetCatInfoSync(&cfb);
  195.             if (!err) {
  196.                 StdIncludeDir = cfb.hFileInfo.ioDirID;
  197.                 StdIncludeVol = cfb.hFileInfo.ioVRefNum;
  198.             }
  199.             else {
  200.                 StdIncludeDir = 0;
  201.                 StdIncludeVol = 0;
  202.             }
  203.         }
  204.  
  205.         {
  206.             CInfoPBRec cfb;
  207.             Str255 tempPath;
  208.             CopyPString("\p(Harvest C Libraries)",tempPath);
  209.             cfb.hFileInfo.ioNamePtr = tempPath;
  210.             cfb.hFileInfo.ioDirID = HarvestCTree.parID;
  211.             cfb.hFileInfo.ioVRefNum = HarvestCTree.vRefNum;
  212.             cfb.hFileInfo.ioFDirIndex = 0;
  213.             err = PBGetCatInfoSync(&cfb);
  214.             if (!err) {
  215.                 StdLibDir = cfb.hFileInfo.ioDirID;
  216.                 StdLibVol = cfb.hFileInfo.ioVRefNum;
  217.             }
  218.             else {
  219.                 StdLibDir = 0;
  220.                 StdLibVol = 0;
  221.             }
  222.         }
  223.     }
  224.     {
  225.         VersRecHndl v;
  226.         v = (VersRecHndl) Get1Resource('vers',1);
  227.         if (v) {
  228.             CopyPString((*v)->shortVersion,MyVersion);
  229.         }
  230.         else {
  231.             CopyPString("\pVersion???",MyVersion);
  232.         }
  233.     }
  234. }
  235.  
  236. void CHarvestApp::DoAppleEvent( CAppleEvent *anAppleEvent)
  237. {
  238.     DescType    eventClass;
  239.     DescType    eventID;
  240.     OSErr        err;
  241.     
  242.     eventClass = anAppleEvent->GetEventClass();
  243.     eventID = anAppleEvent->GetEventID();
  244.     
  245.     if (eventClass == kCoreEventClass)
  246.     {
  247.         switch (eventID)
  248.         {
  249.             case kAEOpenApplication:
  250.                     if (anAppleEvent->GotRequiredParams())
  251.                     {
  252.                         anAppleEvent->SetErrorResult( noErr);
  253.                     }
  254.                     break;
  255.                     
  256.             case kAEOpenDocuments:
  257.                     DoOpenOrPrintDocEvent( anAppleEvent);
  258.                     break;
  259.                     
  260.             case kAEPrintDocuments:
  261.                     err = anAppleEvent->RequestInteraction( MAXLONG);
  262.                     if (err == noErr)
  263.                     {
  264.                         DoOpenOrPrintDocEvent( anAppleEvent);
  265.                     }
  266.                     else
  267.                         anAppleEvent->SetErrorResult( err);
  268.                     break;
  269.                 
  270.             case kAEQuitApplication:
  271.             
  272.                     if (anAppleEvent->GotRequiredParams())
  273.                     {
  274.                         err = anAppleEvent->RequestInteraction( MAXLONG);
  275.                         if (err == noErr)
  276.                         {
  277.                             Quit();
  278.                         
  279.                         }
  280.                         anAppleEvent->SetErrorResult( err);
  281.                     }
  282.                     break;
  283.         }        
  284.     }
  285. }
  286.  
  287. void    CHarvestApp::StartUpAction(
  288.     short    numPreloads)
  289. {
  290.     FlushEvents(everyEvent, 0);
  291.     
  292.     if (!gSystem.hasAppleEvents && (numPreloads == 0))
  293.     {
  294.         gGopher->DoCommand(cmdAbout);
  295.     }
  296. }
  297.  
  298.  
  299. void CHarvestApp::SetUpFileParameters(void)
  300.  
  301. {
  302.     inherited::SetUpFileParameters();    /* Be sure to call the default method */
  303.  
  304.         /**
  305.          **    sfNumTypes is the number of file types
  306.          **    your application knows about.
  307.          **    sfFileTypes[] is an array of file types.
  308.          **    You can define up to 4 file types in
  309.          **    sfFileTypes[].
  310.          **
  311.          **/
  312.  
  313.     sfNumTypes = 3;
  314.     sfFileTypes[0] = 'Hprj';
  315.     sfFileTypes[1] = 'TEXT';
  316.     sfFileTypes[2] = 'OBJ ';
  317.  
  318.     gSignature = 'Jn15';
  319. }
  320.  
  321.  
  322. void CHarvestApp::SetUpMenus()
  323.  {
  324.  
  325.   inherited::SetUpMenus();  /*  Superclass takes care of adding     
  326.                                 menus specified in a MBAR id = 1    
  327.                                 resource    
  328.                             */                          
  329.  
  330.         /* Add your code for creating run-time menus here */    
  331.  }
  332.  
  333.  
  334. /*
  335.  * Handle selection of About item from Apple menu
  336.  */
  337.  
  338. void CHarvestApp::DoAbout(void)
  339. {
  340.     CDLOGDirector *dialog;
  341.     CDialogText *version;
  342.     
  343.     dialog = new CDLOGDirector;    
  344.     dialog->IDLOGDirector( 130, this);
  345.     dialog->BeginDialog();
  346.     version = (CDialogText *) dialog->itsWindow->FindViewByID(3);
  347.     if (version) {
  348.         version->Deactivate();
  349.         version->SetFontNumber(geneva);
  350.         version->SetTextString(MyVersion);
  351.     }
  352.         
  353.     dialog->DoModalDialog( cmdOK);
  354.     ForgetObject(dialog);
  355. }
  356.  
  357. /*
  358.  * Handle selection of Registration... item from Apple menu
  359.  */
  360.  
  361. void CHarvestApp::DoRegistration(void)
  362. {
  363.     CDLOGDirector *dialog;
  364.     
  365.         dialog = new CDLOGDirector;    
  366.         dialog->IDLOGDirector( 230, this);
  367.         dialog->BeginDialog();
  368.             
  369.         dialog->DoModalDialog( cmdOK);
  370.         ForgetObject(dialog);
  371. }
  372.  
  373. void    CHarvestApp::ChooseProjectFile(
  374.     SFReply        *macSFReply)
  375. {
  376.     Point        corner;                    /* Top left corner of dialog box    */
  377.     Boolean        wasLocked;
  378.     SFTypeList    oneType;
  379.                                         /* Center dialog box on the screen    */
  380.     FindDlogPosition('DLOG', sfGetDLOGid, &corner);
  381.     
  382.     wasLocked = Lock( TRUE);
  383.     
  384.     oneType[0] = 'Hprj';
  385.     SFPGetFile(corner, "\p", sfFileFilter, 1, oneType,
  386.                 sfGetDLOGHook, macSFReply, sfGetDLOGid, sfGetDLOGFilter);
  387.                 
  388.     Lock( wasLocked);
  389. }
  390.  
  391. Boolean SamePStrings(char *a,char *b)
  392. {
  393.     int c;
  394.     c = *a;
  395.     while (c--) {
  396.         if (*a != *b) return FALSE;
  397.         a++;b++;
  398.     }
  399.     return TRUE;
  400. }
  401.  
  402. pascal Boolean SourceFileFilter(FileParam * p)
  403. {
  404.     int len;
  405.     int CountSourceFiles;
  406.     int i;
  407.     CSourceFile *aFile;
  408.     /* Now check if it's in the project already. */
  409.     CountSourceFiles = gProject->itsSourceFiles->GetNumItems();
  410.     for (i=1;i<=CountSourceFiles;i++) {
  411.         aFile = (CSourceFile *) gProject->itsSourceFiles->NthItem(i);
  412.         if (SamePStrings((char *) p->ioNamePtr,(char *) aFile->theFile->name)) {
  413.             return TRUE;
  414.         }
  415.     }
  416.     if (p->ioFlFndrInfo.fdType == 'TEXT') {
  417.         len = p->ioNamePtr[0];    /* assume pascal string, of course */
  418.         if (p->ioNamePtr[len] == 'c') {
  419.             if (p->ioNamePtr[len-1] == '.') {
  420.                 return FALSE;
  421.             }
  422.         }
  423.     }
  424.     else if (p->ioFlFndrInfo.fdType == 'OBJ ') {
  425.         return FALSE;
  426.     }
  427.     else if (p->ioFlFndrInfo.fdCreator == 'RSED') {
  428.         return FALSE;
  429.     }
  430.     else if (p->ioFlFndrInfo.fdType == 'rsrc') {
  431.         return FALSE;
  432.     }
  433.     return TRUE;
  434. }
  435.  
  436. void    CHarvestApp::ChooseSourceFile(
  437.     SFReply        *macSFReply)
  438. {
  439.     Point        corner;                    /* Top left corner of dialog box    */
  440.     Boolean        wasLocked;
  441.     SFTypeList    oneType;
  442.                                         /* Center dialog box on the screen    */
  443.     FindDlogPosition('DLOG', sfGetDLOGid, &corner);
  444.     
  445.     wasLocked = Lock( TRUE);
  446.     
  447.     oneType[0] = 'TEXT';
  448.     SFPGetFile(corner, "\p", (FileFilterProcPtr) SourceFileFilter, -1, oneType,
  449.                 sfGetDLOGHook, macSFReply, sfGetDLOGid, sfGetDLOGFilter);
  450.                 
  451.     Lock( wasLocked);
  452. }
  453.  
  454. void    CHarvestApp::ChooseLibFile(
  455.     SFReply        *macSFReply)
  456. {
  457.     Point        corner;                    /* Top left corner of dialog box    */
  458.     Boolean        wasLocked;
  459.     SFTypeList    oneType;
  460.                                         /* Center dialog box on the screen    */
  461.     FindDlogPosition('DLOG', sfGetDLOGid, &corner);
  462.     
  463.     wasLocked = Lock( TRUE);
  464.     
  465.     oneType[0] = 'OBJ ';
  466.     SFPGetFile(corner, "\p", sfFileFilter, 1, oneType,
  467.                 sfGetDLOGHook, macSFReply, sfGetDLOGid, sfGetDLOGFilter);
  468.                 
  469.     Lock( wasLocked);
  470. }
  471.  
  472. void
  473. DoOpenProject(void)
  474. {
  475.     SFReply macSFReply;
  476.     gApplication->ChooseProjectFile(&macSFReply);
  477.     if (macSFReply.good) {
  478.         SetCursor(*gWatchCursor);
  479.         gApplication->OpenProject(&macSFReply);
  480.     }
  481. }
  482.  
  483. void CHarvestApp::DoCommand(long theCommand)
  484. {
  485.     SFReply macSFReply;
  486.     int oldNumTypes;
  487.     switch (theCommand) {
  488.     
  489.         case cmdAbout:
  490.             DoAbout();
  491.             break;
  492.         case cmdRegistration:
  493.             DoRegistration();
  494.             break;
  495.         case cmdNewProject:
  496.         case cmdNew:
  497.                 SetCursor(*gWatchCursor);
  498.             CreateProject();
  499.         break;
  500.         case cmdOpenProject:
  501.         case cmdOpen:
  502.                 DoOpenProject();
  503.         break;
  504.         case cmdDebugger:
  505.             Debugger();
  506.             break;
  507.         case cmdSwitchToAlpha:
  508.             {
  509.                 ProcessSerialNumber process;
  510.                 ProcessInfoRec InfoRec;
  511.                 FSSpec theSpec;
  512.                 if (FindAProcess('ALFA',&process,&InfoRec,&theSpec)) {
  513.                     SetFrontProcess(&process);
  514.                 }
  515.                     /* Maybe later, locate the appl using the desktop manager,
  516.                         and launch it. */
  517.             }
  518.             break;
  519.         default:    inherited::DoCommand(theCommand);
  520.                     break;
  521.     }
  522. }
  523.  
  524.  
  525.  void CHarvestApp::UpdateMenus()
  526.  {
  527.   inherited::UpdateMenus();     /* Enable standard commands */ 
  528.   gBartender->SetDimOption(MENUproject,dimNONE);     
  529.   gBartender->SetDimOption(MENUsources,dimALL);
  530.   gBartender->EnableCmd(cmdTclShell);
  531.   gBartender->EnableCmd(cmdSwitchToAlpha);
  532.   gBartender->EnableCmd(cmdDebugger);
  533.   gBartender->EnableCmd(cmdNewProject);
  534.   gBartender->EnableCmd(cmdOpenProject);
  535.   gBartender->DisableCmd(cmdPageSetup);   
  536.   gBartender->EnableCmd(cmdNew);   
  537.   gBartender->EnableCmd(cmdOpen);
  538.    
  539.   gBartender->DisableCmd(cmdSave);   
  540.   gBartender->DisableCmd(cmdSaveAs);
  541.      
  542.   gBartender->DisableCmd(cmdCloseProject);   
  543.   gBartender->DisableCmd(cmdClose);  
  544.    
  545.   gBartender->DisableCmd(cmdOptions);
  546.   gBartender->DisableCmd(cmdWarnings);
  547.   gBartender->DisableCmd(cmdSetProjectInfo);   
  548.   gBartender->DisableCmd(cmdClean);   
  549.   gBartender->DisableCmd(cmdBringUpToDate);   
  550.   gBartender->DisableCmd(cmdBuildApplication);   
  551.   gBartender->DisableCmd(cmdCheckLink);   
  552.   gBartender->DisableCmd(cmdRun);   
  553.  
  554.     /* Enable the commands handled by your Application class */ 
  555.  }
  556.  
  557.  
  558. void CHarvestApp::Exit()
  559.  
  560. {
  561.     /* your exit handler here */
  562. }
  563.  
  564.  
  565. void CHarvestApp::CreateProject()
  566.  
  567. {
  568.     CHarvestDoc *newDocument;
  569.     newDocument = new(CHarvestDoc);
  570.     newDocument->IHarvestDoc(this,false);
  571.     newDocument->NewFile();
  572. }
  573.  
  574. void CHarvestApp::CreateDocument()
  575.  
  576. {
  577.     CHarvestDoc *newDocument;
  578.     newDocument = new(CHarvestDoc);
  579.     newDocument->IHarvestDoc(this,false);
  580.     newDocument->NewFile();
  581. }
  582.  
  583. void CHarvestApp::OpenDocument(SFReply *macSFReply)
  584.  
  585. {
  586.     CHarvestDoc    *theDocument = NULL;
  587.     
  588.     TRY
  589.     {
  590.     
  591.         theDocument = new(CHarvestDoc);
  592.             
  593.             /**
  594.              **    Send your document an initialization
  595.              **    message. The first argument is the
  596.              **    supervisor (the application). The second
  597.              **    argument is TRUE if the document is printable.
  598.              **
  599.              **/
  600.         
  601.         theDocument->IHarvestDoc(this, false);
  602.     
  603.             /**
  604.              **    Send the document an OpenFile() message.
  605.              **    The document will open a window, open
  606.              **    the file specified in the macSFReply record,
  607.              **    and display it in its window.
  608.              **
  609.              **/
  610.         theDocument->OpenFile(macSFReply);
  611.     }
  612.     
  613.     CATCH
  614.     {
  615.         /*
  616.          * This exception handler gets executed if a failure occurred 
  617.          * anywhere within the scope of the TRY block above. Since 
  618.          * this indicates that the document could not be opened, we
  619.          * send it a Dispose message. The exception will propagate up to
  620.          * CSwitchboard's exception handler, which handles displaying
  621.          * an error alert.
  622.          */
  623.          
  624.          if (theDocument) theDocument->Dispose();
  625.     }
  626.     ENDTRY;
  627. }
  628.  
  629. void CHarvestApp::OpenProject(SFReply *macSFReply)
  630.  
  631. {
  632.     CHarvestDoc    *theDocument = NULL;
  633.     
  634.     TRY
  635.     {
  636.     
  637.         theDocument = new(CHarvestDoc);
  638.             
  639.             /**
  640.              **    Send your document an initialization
  641.              **    message. The first argument is the
  642.              **    supervisor (the application). The second
  643.              **    argument is TRUE if the document is printable.
  644.              **
  645.              **/
  646.         
  647.         theDocument->IHarvestDoc(this, false);
  648.     
  649.             /**
  650.              **    Send the document an OpenFile() message.
  651.              **    The document will open a window, open
  652.              **    the file specified in the macSFReply record,
  653.              **    and display it in its window.
  654.              **
  655.              **/
  656.         theDocument->OpenFile(macSFReply);
  657.     }
  658.     
  659.     CATCH
  660.     {
  661.         /*
  662.          * This exception handler gets executed if a failure occurred 
  663.          * anywhere within the scope of the TRY block above. Since 
  664.          * this indicates that the document could not be opened, we
  665.          * send it a Dispose message. The exception will propagate up to
  666.          * CSwitchboard's exception handler, which handles displaying
  667.          * an error alert.
  668.          */
  669.          
  670.          if (theDocument) theDocument->Dispose();
  671.     }
  672.     ENDTRY;
  673. }
  674.  
  675. OSErr
  676. FindOMFFile(char *name,short volrefnum, long dirID, FSSpec *f)
  677. {
  678.   FInfo junk;
  679.   OSErr bad;
  680.   Str255 pname;
  681.  
  682.   strcpy(f->name,name);
  683.   strcpy(pname,name);
  684.   c2pstr(pname);
  685.   
  686.   /* Search path : current app dir, lib dir, etc... */
  687.   
  688.   bad = HGetFInfo(f->vRefNum = volrefnum, f->parID = dirID,pname,&junk);
  689.   if (!bad) return bad;
  690.  
  691.   bad = HGetFInfo(f->vRefNum = gProject->StdAppVol, f->parID = gProject->StdAppDir,pname,&junk);
  692.   if (!bad) return bad;
  693.  
  694.   bad = HGetFInfo(f->vRefNum = gApplication->StdLibVol, f->parID = gApplication->StdLibDir,pname,&junk);
  695.   if (!bad) return bad;
  696.   
  697.   return bad;
  698. }
  699.  
  700. OSErr
  701. FindCFile(char *name,short volrefnum, long dirID, FSSpec *f)
  702. {
  703.   FInfo junk;
  704.   OSErr bad;
  705.   Str255 pname;
  706.  
  707.   strcpy(f->name,name);
  708.   strcpy(pname,name);
  709.   c2pstr(pname);
  710.   
  711.   /* Search path : current app dir, lib dir, etc... */
  712.   
  713.   bad = HGetFInfo(f->vRefNum = volrefnum, f->parID = dirID,pname,&junk);
  714.   if (!bad) return bad;
  715.  
  716.   bad = HGetFInfo(f->vRefNum = gProject->StdAppVol, f->parID = gProject->StdAppDir,pname,&junk);
  717.   if (!bad) return bad;
  718.  
  719.   bad = HGetFInfo(f->vRefNum = gApplication->StdLibVol, f->parID = gApplication->StdLibDir,pname,&junk);
  720.   if (!bad) return bad;
  721.   
  722.   return bad;
  723. }
  724.  
  725. void CHarvestApp::SpinCursor(void)
  726. {
  727.     EventRecord junk;
  728.     BeachIndex = (BeachIndex + 1) % 4;
  729.     SetCursor(*(BeachBalls[BeachIndex]));
  730.  
  731.     /* should maybe give time to background processes here, but maybe not */
  732. }
  733.  
  734.